<script setup>
import {getTeachingTask} from "/src/api/hbmy_wx/TeachingTaskService";
import {onBeforeRouteLeave} from "vue-router";

const TeachingTaskList = ref([0,1,2])
let activeName = ref([])
const collapseRef = ref(null)
const getClassArray = (className) => {
  // 使用空格分隔字符串并去除空字符串
  return className.split(/\s+/).filter(Boolean);
}
onMounted(async () => {
  const res = await getTeachingTask()
  TeachingTaskList.value = JSON.parse(res.response.value.extend.teachingTask)
  console.log(TeachingTaskList.value)
  // await nextTick(() => {
  //   collapseRef.value.toggleAll(true);
  // });

})


</script>

<!--<template>-->
<!--  <Header title="教学任务"></Header>-->
<!--  <van-collapse v-model="activeName" ref="collapseRef" >-->
<!--    <van-collapse-item-->
<!--        style="margin-top:15px; padding:0 10px;"-->
<!--        v-for="(task,index) in TeachingTaskList"-->
<!--        :key="index"-->
<!--        :name="index"-->
<!--        :is-link="false"-->
<!--        :readonly="true"-->
<!--        size="large">-->
<!--      <template #title>-->
<!--        <span style="height:100%;line-height: 3vh; border-left: 5px solid #1989fa; margin-right: 5px"></span>-->
<!--        {{task.courseName}}-->
<!--      </template>-->
<!--      <van-row gutter="5">-->
<!--        任课班级:-->
<!--        <van-col-->
<!--            v-for="(classItem, index) in getClassArray(task.className)"-->
<!--            :key="index">-->
<!--          {{ classItem }}</van-col>-->
<!--      </van-row>-->
<!--      <van-row style="margin-top: 5px">-->
<!--        <van-col span="8"> 理论学时:{{task.theoryHour}}</van-col>-->
<!--        <van-col span="8">总学时:{{task.courseHour}}</van-col>-->
<!--        <van-col span="8">容纳人数:{{task.stuCnt}}</van-col>-->
<!--      </van-row>-->
<!--    </van-collapse-item>-->
<!--  </van-collapse>-->
<!--  <van-empty v-if="TeachingTaskList == null" image="search" description="无教学任务"/>-->
<!--</template>-->



<template>
  <Header title="教学任务"></Header>
  <van-empty v-if="TeachingTaskList == null" image="search" description="无教学任务"/>
  <van-cell v-for="task in TeachingTaskList" style="margin: 0 4vw 3vw 4vw;width: 92vw">
    <span style="height:100%;line-height: 3vh; border-left: 5px solid #1989fa; margin-right: 5px"></span>
    <span>{{task.courseName}}</span>
    <van-divider :margin="6" />
    <div style="color: #9a9b9d">
      <p>任课班级:{{task.className}}</p>
      <van-row style="margin-top: 5px; white-space: nowrap;">
        <van-col span="8"> 理论学时:{{task.theoryHour}}</van-col>
        <van-col span="8">总学时:{{task.courseHour}}</van-col>
        <van-col span="8">容纳人数:{{task.stuCnt}}</van-col>
      </van-row>
    </div>
  </van-cell>
</template>



